﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Silmoon;
using System.Collections.Specialized;
using Levi.Finance.Server.Common;
namespace Levi.Finance.Server
{
	public class Configure
	{
		ABC g;
        public string db_mongodb_server;
        public string db_mongodb_database;
        public string db_mongodb_username;
        public string db_mongodb_password;

        public string server_setting_type;
        public string server_setting_max_udp_packet;
        public bool server_setting_debug = false;

        public string server_net_bindip;
        public string server_net_port;

        public Configure(ABC _g)
        {
            g = _g;
            loadConfigureFile();
        }
        void loadConfigureFile()
        {
            string configFilePath = System.Windows.Forms.Application.StartupPath + "/config.conf";
            //configFilePath = "c:\\cookydns.conf";
            if (!string.IsNullOrEmpty(g.Parameters["--configure"]))
                configFilePath = g.Parameters["--configure"];
            string[] configureLine = File.ReadAllLines(configFilePath);
            NameValueCollection parameters = SmString.AnalyzeNameValue(configureLine, "=", "");

            db_mongodb_server = parameters["db_mongodb_server"];
            db_mongodb_database = parameters["db_mongodb_database"];
            db_mongodb_username = parameters["db_mongodb_username"];
            db_mongodb_password = parameters["db_mongodb_password"];

            server_setting_type = parameters["server_setting_type"];
            server_setting_max_udp_packet = parameters["server_setting_max_udp_packet"];
            server_setting_debug = SmString.StringToBool(parameters["server_setting_debug"]);

            server_net_bindip = parameters["server_net_bindip"];
            server_net_port = parameters["server_net_port"];
        }
	}
}

